//
//  KIDBAWAdvertisementManager.h
//  VISIKARD
//
//  Created by Phan Ba Minh on 9/5/12.
//  Copyright (c) 2012 kidbaw. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <iAd/iAd.h>
//#import "MPAdView.h"
//#import "GADBannerView.h"

#define STRING_USER_DEFAULT_KIDBAW_ADVERTISEMENT_MANAGER                    @"STRING_USER_DEFAULT_KIDBAW_ADVERTISEMENT_MANAGER"
#define WIDTH_KIDBAW_ADVERTISEMENT_BANNER                                   320
#define TIMER_SHOWING_BANNER                                            30
#define TIMER_WAITING_USER_STOP_SWIPE_ON_BANNER                         5
#define TIMER_HIDING_BANNER                                             2
#define TIMER_RELOADING_BANNER                                          30
#define TIMER_RELOADING_WEB_BANNER                                      15

#define ADMOD_BANNER_UNIT_ID                                            @"a1506f0336bb3e1"
#define MOPUB_BANNER_UNIT_ID                                            @"agltb3B1Yi1pbmNyDQsSBFNpdGUYq6aYEww"

typedef enum {
    enumKIDBAWAdvertisementIsAllowed_Invalid,
    enumKIDBAWAdvertisementIsAllowed_Prevented,
    enumKIDBAWAdvertisementIsAllowed_Hidden,
    enumKIDBAWAdvertisementIsAllowed_Showed
}enumKIDBAWAdvertisementIsAllowed;


typedef enum {
    enumKIDBAWAdvertisementStatus_Invalid,
    enumKIDBAWAdvertisementStatus_iAd_Finished,
    enumKIDBAWAdvertisementStatus_iAd_Failed,
    enumKIDBAWAdvertisementStatus_AdMod_Finished,
    enumKIDBAWAdvertisementStatus_AdMod_Failed,
    enumKIDBAWAdvertisementStatus_MoPub_Finished,
    enumKIDBAWAdvertisementStatus_MoPub_Failed,
    enumKIDBAWAdvertisementStatus_KIDBAW_Finished,
    enumKIDBAWAdvertisementStatus_KIDBAW_Loading,
    enumKIDBAWAdvertisementStatus_KIDBAW_Failed
}enumKIDBAWAdvertisementStatus;

typedef enum {
    enumKIDBAWAdvertisementType_Invalid = -1,
    enumKIDBAWAdvertisementType_iAd,
    enumKIDBAWAdvertisementType_AdMod,
    enumKIDBAWAdvertisementType_MoPub,
    enumKIDBAWAdvertisementType_Sum
}enumKIDBAWAdvertisementType;

typedef enum {
    enumKIDBAWAdvertisementPriority_Invalid,
    enumKIDBAWAdvertisementPriority_iAd = 1,
    enumKIDBAWAdvertisementPriority_AdMod = 2,
    enumKIDBAWAdvertisementPriority_MoPub = 4
}enumKIDBAWAdvertisementPriority;

typedef enum {
    enumKIDBAWAdvertisementAnimation_Invalid,
    enumKIDBAWAdvertisementAnimation_FromBottomToTop,
    enumKIDBAWAdvertisementAnimation_FromRightToLeft
}enumKIDBAWAdvertisementAnimation;

@protocol KIDBAWAdvertisementProtocol <NSObject>
@optional
- (void)loadInterfaceKIDBAWAdvertisementCallBack;
@end

//@interface KIDBAWAdvertisementManager : NSObject <UIWebViewDelegate, ADBannerViewDelegate, MPAdViewDelegate, GADBannerViewDelegate> {
@interface KIDBAWAdvertisementManager : NSObject <UIWebViewDelegate, ADBannerViewDelegate> {
    CGRect                                      _frameShowedAds;
    CFAbsoluteTime                              _timeShowedAds;
    CFAbsoluteTime                              _timeReloadedAds;
    
    enumKIDBAWAdvertisementPriority                 _priorityAds;
    enumKIDBAWAdvertisementAnimation                _animationAds;
    NSMutableArray                              *_viewAdsList;
    
    UIView                                      *_mainView;
    UIView                                      *_viewInstanceOld;
    UIView                                      *_viewInstanceNew;
    
    enumKIDBAWAdvertisementType                     _indexAds;
    enumKIDBAWAdvertisementStatus                   _statusAds;
    enumKIDBAWAdvertisementIsAllowed                _isAllowed;
    UIViewController                            *_viewControllerAds;
    id<KIDBAWAdvertisementProtocol>                 _delegate;
    
    UIImageView                                 *_imgViewPlaceHolder;
}


+ (KIDBAWAdvertisementManager *)Shared;
- (void)startAdsInView:(UIViewController *)viewcontroller andBannerFrame:(CGRect)frame andDelegate:(id<KIDBAWAdvertisementProtocol>)del;
- (void)update;
- (void)loadInterface;
- (void)initAds;
- (void)loadNextAdsType;

- (void)showAdsWithAnimation:(enumKIDBAWAdvertisementAnimation)animation;
- (void)hideAdsWithAnimation:(enumKIDBAWAdvertisementAnimation)animation;
- (void)preventAds;
- (void)allowAds;
- (void)refreshAds;

@end
